package com.thon.entity.user;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.thon.entity.project.Project;
import com.thon.entity.util.IdEntity;

	@Entity
	@Table(name = "coupon")
	@JsonIgnoreProperties(ignoreUnknown = true)
	public class Coupon extends IdEntity {
		
		/**
		 * 优惠券
		 */
		private static final long serialVersionUID = 1L;
		private String label;
		private String couponExplain;
		private Integer couponValue;
		private String couponNo;
		private User user;
		private String couponStatus;//0:未使用，1：使用，2：废弃
		private User created_by;
		private Date createdDate;
		private Date overdueDate;
		private String memo;
		private Integer addressId; //优惠券地址id(实物券)
		private Project project; //根据project_id获得project信息
		
		//优惠券状态
		public static final String STATUS_UNUSE="0";
		public static final String STATUS_USED="1";
		public static final String STATUS_DISCARD="2";
		
		//优惠券类型
		public static final String TYPE_GOODS="goods";
		public static final String TYPE_MONEY="money";
		public static final String TYPE_ACTIVITY="activity";
		
		public Coupon(){
		}

		public String getLabel() {
			return label;
		}

		public void setLabel(String label) {
			this.label = label;
		}

		public Integer getCouponValue() {
			return couponValue;
		}

		public void setCouponValue(Integer couponValue) {
			this.couponValue = couponValue;
		}
		
		@OneToOne(cascade = CascadeType.MERGE)
		@JoinColumn(name = "user_id")
		public User getUser() {
			return user;
		}

		public void setUser(User user) {
			this.user = user;
		}
		
		
		public String getCouponExplain() {
			return couponExplain;
		}

		public void setCouponExplain(String couponExplain) {
			this.couponExplain = couponExplain;
		}

		public String getCouponNo() {
			return couponNo;
		}

		public void setCouponNo(String couponNo) {
			this.couponNo = couponNo;
		}

		public String getCouponStatus() {
			return couponStatus;
		}

		public void setCouponStatus(String couponStatus) {
			this.couponStatus = couponStatus;
		}

		@ManyToOne(cascade = CascadeType.MERGE)
		@JoinColumn(name= "project_id")
		public Project getProject() {
			return project;
		}

		public void setProject(Project project) {
			this.project = project;
		}

		@OneToOne(cascade = CascadeType.MERGE)
		@JoinColumn(name = "created_by")
		public User getCreated_by() {
			return created_by;
		}

		public void setCreated_by(User created_by) {
			this.created_by = created_by;
		}

		public String getMemo() {
			return memo;
		}

		public void setMemo(String memo) {
			this.memo = memo;
		}
		@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
		public Date getOverdueDate() {
			return overdueDate;
		}

		public void setOverdueDate(Date overdueDate) {
			this.overdueDate = overdueDate;
		}
		@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
		public Date getCreatedDate() {
			return createdDate;
		}

		public void setCreatedDate(Date createdDate) {
			this.createdDate = createdDate;
		}

		public Integer getAddressId() {
			return addressId;
		}

		public void setAddressId(Integer addressId) {
			this.addressId = addressId;
		}
		
}
